/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var fieldLabel = new Array('D类');
var fieldLabel1 = new Array('单位名称','全部测点数','A类测点数','B类测点数','C类测点数','城网测点数','农网测点数','合计测点数');
var fieldName=new Array("orgName","total","A","B","C","DC","DN","D",'rn');
var _pageSize=20;

var now = new Date();
var store=new Ext.data.JsonStore({    
    url: "../../../servlet/system/PointLoad",
    root: 'data',
    idProperty: 'id',
    totalProperty: 'count',
    fields: fieldName,
    autoLoad: true,
    baseParams:{reportStatus:reportStatus,cmd:cmd,dateTo:now.format('Ym'),start:0,limit:99999}
});

var centercolumnModel = new Ext.grid.ColumnModel({
    columns: [
    {header: '序号',width: 40, dataIndex: 'rn', align: 'center'},    
    {
        header: fieldLabel1[0], 
        width: 100, 
        dataIndex: fieldName[0], 
        align: 'center'
    },
    {
        header: fieldLabel1[1], 
        width: 100, 
        dataIndex: fieldName[1], 
        align: 'center'
    },

    {
        header: fieldLabel1[2], 
        width: 100, 
        dataIndex: fieldName[2], 
        align: 'center'
    },

    {
        header: fieldLabel1[3], 
        width: 100, 
        dataIndex: fieldName[3], 
        align: 'center'
    },

    {
        header: fieldLabel1[4], 
        width: 100, 
        dataIndex: fieldName[4], 
        align: 'center'
    },

    {
        header: fieldLabel1[5], 
        width: 100, 
        dataIndex: fieldName[5], 
        align: 'center'
    },

    {
        header: fieldLabel1[6], 
        width: 100, 
        dataIndex: fieldName[6], 
        align: 'center'
    },

    {
        header: fieldLabel1[7], 
        width: 100, 
        dataIndex: fieldName[7], 
        align: 'center'
    }
    ],
    defaultSortable: true,
    rows: [
    [
    {
        width: 100, 
        rowspan: 1
    },

    {
        width: 100, 
        rowspan: 1
    },

    {
        width: 100, 
        rowspan: 1
    },
    {
        width: 100, 
        rowspan: 1
    },

    {
        width: 100, 
        rowspan: 1
    },
    {
        width: 100, 
        rowspan: 1
    },
    {
        width: 100, 
        header: fieldLabel[0], 
        colspan: 3, 
        align: 'center'
    }
    ]
    ]
});

var dateTo = {
    xtype: 'datefield',
    id: 'DateTo',
    format: 'Y年m月',
    width: 150,
    value:now,
    listeners: {
        select: function(c, date) {            
            store.baseParams.dateTo = date.format('Ym');
        }
    }  
};
var centergrid=new Ext.grid.GridPanel({
    title: _title,
    store: store,
    colModel:centercolumnModel,
    enableColumnMove: false,
    viewConfig: {
        forceFit: true
    },
    plugins: [new Ext.ux.plugins.GroupHeaderGrid()],
    loadMask: true,
    tbar: new Ext.Toolbar([
        reportCombo,        
        rangeCombo,
        '-',
        dateTo,
    searchButton,
    '-',
    {
        xtype: 'button',
        text: '导出',
        iconCls: 'icon-excel',
        width: 60,
        style: {
            marginLeft: '20px'
        },
        handler: downloadExcel
    }
    ]),
    bbar: new Ext.PagingToolbar({
        pageSize: _pageSize,
        store: store,
        displayInfo: true,
        displayMsg: '显示记录：{0} - {1}   总记录：{2}',
        emptyMsg:  '目前没有信息'
    })
});


function downloadExcel(){    
    store.baseParams.type=1;
    var encodeParams = Ext.urlEncode(store.baseParams);
    open('../../../servlet/common/ExcelFileCreate?'+encodeParams);
}

function buildWindow(){
    var applicationUI = new Ext.Viewport({
        layout:'fit',
        items: [
        centergrid
        ]
    });
    if(reportStatus ===1){
        //Ext.getCmp('ReportStatus').setVisible(false);
        Ext.getCmp('ReportStatus').setValue(1);
    }
}
Ext.onReady(buildWindow); 